﻿<?php
$CI =& get_instance();
$CI->load->library('pagination');
$CI->load->model('Model_product', 'model_product');

$t1 = $content['t1'];
$t1 = unserialize($t1);
$media_thumb = $CI->config->item("media_thumb");
$total = $CI->model_product->browse_count(null,null,null);
$offset = 0;
$per_page = $this->uri->segment(2,0);
if($per_page < $total){
	$offset = $per_page;
}
$limit = $t1['quantity'];
$product_list = $CI->model_product->browse(null,null,null,$limit,$offset);

$config['base_url'] = site_url(array('c'=>'home', 'm'=>'index', 'nav'=>$node['id']));
$config['uri_segment'] = 2;
$config['total_rows'] = $total;
$config['per_page'] = $limit;
$config['first_link'] = "Đầu tiên";
$config['last_link'] = "Cuối cùng";

$CI->pagination->initialize($config);
?>
<div class="one-col">
	<h1 style="display:none;"><?= $content['title'];?></h1>
	<div class="product-cont">
		<?php if(!empty($product_list)):?>		
			<div class="product-grid">
				<?php foreach($product_list as $item):?>
					<div class="item">
						<a class="customGal" href="<?=$media_thumb['user_media_url'].$item['rawname'].$item["fileext"]?>" title="<?=$item['description']?>" style="width: 200px">
							<img src="<?=$media_thumb['user_media_url'].$item['rawname'].$media_thumb['thumb_marker'].$item["fileext"]?>" alt="<?=$item['title']?>" width="200" height="150"/>							
						</a>
						<br/>
						<div class="meta">
							<a href="javascript:;" class="keycode" title="Mã sản phẩm"><span><?=$item['keycode']?></span></a>
							<a href="<?=site_url(array('c' => 'home', 'm' => 'index', 'node_id' => 4, 'url_title' => 'lien-he'));?>" class="price" title="Giá tiền"><span><?=number_format($item['price'], 0, ',', '.')?> VNĐ</span></a>
						</div>
					</div>
				<?php endforeach; ?>
				<div class="clearfix"></div>
				<div class="pagination"><?=$CI->pagination->create_links();?></div>
			</div>
		<?php endif;?>
	</div>
</div>
<script language="JavaScript" type="text/javascript">
$(document).ready(function() {
	// cal width and height span border
	/*$(".customGal").each(function(){
		$(this).find(".product-bg").width($(this).width()).height($(this).height());				
	});*/
	// Zoom image
	$('.product-grid a.customGal').lightBox({imageLoading : 'public/images/lightbox-ico-loading.gif',imageBtnPrev : 'public/images/lightbox-btn-prev.gif',imageBtnNext : 'public/images/lightbox-btn-next.gif',imageBtnClose : 'public/images/lightbox-btn-close.gif',imageBlank : 'public/images/lightbox-blank.gif'});	
});
</script>